<?php

/**
 * Description of VirtualLabs_Admin_Network
 *
 * @author markos
 */
class VirtualLabs_Admin_Network extends VirtualLabs_Admin_Dao {

    const TABLE_NAME = 'red_laboratorio';

    private $debugLog;
    private $errorLog;

    public function __construct() {
        $this->debugLog = Zend_Registry::get(VirtualLabs_Common::DEBUG_LOG);
        $this->errorLog = Zend_Registry::get(VirtualLabs_Common::ERROR_LOG);
    }

    /**
     * Recupera la informacion de red de un laboratorio con $codigoLaboratorio.
     * 
     * @param int $codigoLaboratorio codigo de laboratorio al que pertenece la configuracion de red
     * @return array (network_id, gateway, netmask) as an array of strings
     * @throws Exception 
     */
    public function getNetworkByLab($codigoLaboratorio) {
        $db = Zend_Db_Table::getDefaultAdapter();
        try {
            $select = $db->select()->from("red_laboratorio", array("network_id", "gateway", "netmask"))
                    ->where("codigo_laboratorio = ?", $codigoLaboratorio);
            return $db->fetchRow($select);
        } catch (Exception $e) {
            $this->debugLog->debug($e->getMessage());
            $this->debugLog->debug($e->getTraceAsString());
            throw $e;
        }
    }

}

?>
